{% extends "base.html" %}
{% block header %}权限管理{% endblock %}
{% block content %}
<div class="container-fluid py-4">
    <div class="row justify-content-center">
        <div class="col-lg-10">
            <div class="card shadow-sm rounded">
                <div class="card-body">
                    <div class="d-flex justify-content-between align-items-center mb-3">
                        <h3 class="card-title mb-0">权限管理</h3>
                        <a href="/add_permission/" class="btn btn-success">+ 添加权限</a>
                    </div>
                    <form class="mb-3" method="get" action="">
                        <div class="input-group">
                            <input type="text" name="q" class="form-control" placeholder="搜索权限..." value="{{ request.GET.q }}">
                            <button class="btn btn-outline-primary" type="submit">搜索</button>
                        </div>
                    </form>
                    <div class="table-responsive">
                        <table class="table table-bordered align-middle">
                            <thead class="table-light">
                                <tr>
                                    <th>权限名称</th>
                                    <th>标识</th>
                                    <th style="width:160px;">操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                {% for perm in permissions %}
                                <tr>
                                    <td>{{ perm.name }}</td>
                                    <td>{{ perm.codename }}</td>
                                    <td>
                                        <a href="/edit_permission/{{ perm.id }}/" class="btn btn-sm btn-primary me-2">编辑</a>
                                        <a href="/delete_permission/{{ perm.id }}/" class="btn btn-sm btn-danger" onclick="return confirm('确定要删除该权限吗？');">删除</a>
                                    </td>
                                </tr>
                                {% empty %}
                                <tr><td colspan="3" class="text-center">暂无权限信息</td></tr>
                                {% endfor %}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}